import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;

class Transaction {
    private Date date;
    private double amount;
    private String category;
    private String note;

    public Transaction(Date date, double amount, String category, String note) {
        this.date = date;
        this.amount = amount;
        this.category = category;
        this.note = note;
    }

    public double getAmount() {
        return amount;
    }

    public String getCategory() {
        return category;
    }

    @Override
    public String toString() {
        return String.format("%s - %.2f - %s - %s", date.toString(), amount, category, note);
    }
}

class BudgetManager {
    private List<Transaction> incomeRecords;
    private List<Transaction> expenseRecords;

    public BudgetManager() {
        this.incomeRecords = new ArrayList<>();
        this.expenseRecords = new ArrayList<>();
    }

    public void addIncome(Date date, double amount, String category, String note) {
        if (amount <= 0) {
            throw new IllegalArgumentException("收入金额必须为正数");
        }
        Transaction transaction = new Transaction(date, amount, category, note);
        incomeRecords.add(transaction);
    }

    public void addExpense(Date date, double amount, String category, String note) {
        if (amount <= 0) {
            throw new IllegalArgumentException("支出金额必须为正数");
        }
        Transaction transaction = new Transaction(date, amount, category, note);
        expenseRecords.add(transaction);
    }

    public List<Transaction> getIncomeRecords() {
        return incomeRecords;
    }

    public List<Transaction> getExpenseRecords() {
        return expenseRecords;
    }


}

class PersonalFinanceManager {
    public static void main(String[] args) {
        BudgetManager manager = new BudgetManager();
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("\n个人账单管理系统");
            System.out.println("1. 记录收入");
            System.out.println("2. 记录支出");
            System.out.println("0. 退出");

            System.out.print("请选择操作：");
            String choice = scanner.nextLine();

            switch (choice) {
                case "1":
                    System.out.print("请输入日期 (YYYY-MM-DD): ");
                    String dateStr = scanner.nextLine();
                    System.out.print("请输入收入金额: ");
                    double incomeAmount = Double.parseDouble(scanner.nextLine());
                    System.out.print("请输入收入类别: ");
                    String incomeCategory = scanner.nextLine();
                    System.out.print("请输入备注: ");
                    String incomeNote = scanner.nextLine();
                    manager.addIncome(new Date(), incomeAmount, incomeCategory, incomeNote);
                    System.out.println("收入记录成功！");
                    break;

                case "2":
                    System.out.print("请输入日期 (YYYY-MM-DD): ");
                    dateStr = scanner.nextLine();
                    System.out.print("请输入支出金额: ");
                    double expenseAmount = Double.parseDouble(scanner.nextLine());
                    System.out.print("请输入支出类别: ");
                    String expenseCategory = scanner.nextLine();
                    System.out.print("请输入备注: ");
                    String expenseNote = scanner.nextLine();
                    manager.addExpense(new Date(), expenseAmount, expenseCategory, expenseNote);
                    System.out.println("支出记录成功！");
                    break;


                case "0":
                    System.out.println("退出系统。");
                    scanner.close();
                    return;

            }
        }
    }
}